const s = "Let's take LeetCode contest"
// 输出："s'teL ekat edoCteeL tsetnoc"

var reverseWords = function (s) {
    const st = s.split(' ');
    return st.map(e => reverse(e.split(''))).join(' ');
};

function reverse(arr) {
    let i = 0;
    let j = arr.length - 1;
    while (i < j) {
        [arr[j], arr[i]] = [arr[i], arr[j]];
        i++;
        j--;
    }
    return arr.join('');
}

console.log(reverseWords(s));